﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using BoardPACUtil.Util;

namespace BoardPACUtil.Enums
{
    /// <summary>
    ///  <title></title>
    ///  <description></description>
    ///  <copyRight>Copyright (c) 2012</copyRight>
    ///  <company>IronOne Technologies (Pvt)Ltd</company>
    ///  <createdOn>2012-</createdOn>
    ///  <author></author>
    ///  <modification>
    ///     <modifiedBy></modifiedBy>
    ///      <modifiedDate></modifiedDate>
    ///     <description></description>
    ///  </modification>
    /// </summary>
    class EnumContainer
    {


    }

    public enum SaluationType
    {
        [Description("Mr.")]
        Mr,
        [Description("Mrs.")]
        Mrs,
        [Description("Ms.")]
        Miss,
        [Description("Dr.")]
        Dr,
        [Description("Prof.")]
        Prof,
        [Description("Rev.")]
        Rev,
        [Description("N/A")]
        na
    }

    #region Meetings
    public enum MeetingType : byte
    {
        Meeting = 0,
        Circular
    }

    public enum MeetingStatus : byte
    {
        Pending = 0,
        Open,
        Close,
        Cancelled,
        Confirmed
    }
    #endregion

    #region Papers
    public enum DecisionStatus
    {
        [Description("Pending")]
        Pending = 0,

        [Description("Approve")]
        Approve = 1,

        [Description("Rejected")]
        Reject = 2,

        [Description("Abstain")]
        Abstain = 3,

        [Description("Interest")]
        Interest = 4,

        [Description("RPT")]
        RPT = 5
    }
    
    public enum ScrollDirection
    {
        [Description("Right Left")]
        RightLeft,
        [Description("Up Down")]
        UpDown
    }

    public enum DocumentType
    {
        [Description("Paper for Approval")]
        BoardPaper,
        [Description("Information Paper")]
        InformationPaper,
        [Description("Discussion Item")]
        DiscussionItem,
        [Description("Support Document")]
        SupportDocument,
        [Description("Discussion Paper")]
        DiscussionPaper
    }

    public enum PaperStatus
    {
        [Description("Pending")]
        Pending,
        [Description("Approved")]
        Approved,
        [Description("Rejected")]
        Rejected,
        [Description("Carried Forward")]
        CarriedForward,
        [Description("Deleted")]
        Cancelled,
        [Description("Confirmed")]
        Confirmed,
        [Description("Withdrawn")]
        Withdrawn
    }

    public enum InfoOnlyPaperStatus
    {
        [Description("Pending")]
        Pending,
        [Description("Carried Forward")]
        CarriedForward,
        [Description("Deleted")]
        Cancelled,
        [Description("Confirmed")]
        Confirmed,
        [Description("Withdrawn")]
        Withdrawn
    }

    public enum PaperNotificationStatus
    {
        [Description("New Not Read")]
        New,
        [Description("Read")]
        Viewed,
        [Description("Updated Not Read")]
        Updated
    }

    public static class DecisionStatusExtention
    {
        //  private static ILog EventLog = LogManager.GetLogger("EventLog");
        //  private static ILog ErrorLog = LogManager.GetLogger("ErrorLog");

        private const string PENDING_IMAGE = "pending_status.png";
        private const string APPROVE_IMAGE = "approve.png";
        private const string REJECTED_IMAGE = "reject.png";
        private const string ABSTAIN_IMAGE = "abstain.png";
        private const string INTEREST_IMAGE = "interest.png";
        private const string RPT_Image = "rpt.png";

        public static string GetImage(this DecisionStatus decisionStatus)
        {
            // EventLog.Info(String.Format(Resources.log_evt_entry_DecisionStatus_GetImage, EventStatus.Entry.ToString()));

            switch (decisionStatus)
            {
                case DecisionStatus.Pending: return PENDING_IMAGE;
                case DecisionStatus.Approve: return APPROVE_IMAGE;
                case DecisionStatus.Reject: return REJECTED_IMAGE;
                case DecisionStatus.Abstain: return ABSTAIN_IMAGE;
                case DecisionStatus.Interest: return INTEREST_IMAGE;
                case DecisionStatus.RPT: return RPT_Image;
            }

            // EventLog.Info(String.Format(Resources.log_evt_success_DecisionStatus_GetImage, EventStatus.Success.ToString()));

            return string.Empty;
        }

        public static string GetResourceString(this DecisionStatus decisionStatus)
        {
            switch (decisionStatus)
            {
                case DecisionStatus.Pending: return "info_Pending";
                case DecisionStatus.Approve: return "info_gen_Approved";
                case DecisionStatus.Reject: return "info_Reject";
                case DecisionStatus.Abstain: return "info_Abstain";
                case DecisionStatus.Interest: return "info_Interest";
                case DecisionStatus.RPT: return "info_RPT";
            }
            return string.Empty;
        }

        /// <summary>
        /// Gets the description of the enum specified by the enum attribute
        /// </summary>
        /// <param name="decisionStatus">DecisionStatus enum</param>
        /// <returns>enum description</returns>
        public static string GetDescription(this DecisionStatus decisionStatus)
        {
            //EventLog.Info(String.Format(Resources.log_evt_entry_DecisionStatus_GetDescription, EventStatus.Entry.ToString()));
            return EnumUtility.GetEnumDescription(decisionStatus);
        }

        /// <summary>
        /// Gets the value of the enum specified by the enum declaration
        /// </summary>
        /// <param name="decisionStatus">DecisionStatus enum</param>
        /// <returns>enum description</returns>
        public static int GetValue(this DecisionStatus decisionStatus)
        {
            //  EventLog.Info(String.Format(Resources.log_evt_entry_DecisionStatus_GetValue, EventStatus.Entry.ToString()));

            return (int)decisionStatus;
        }

        /// <summary>
        /// Gets the DecisionStatus enum values specific to the client
        /// </summary>
        /// <param name="meetingType">Meeting Type</param>
        /// <returns>list DecisionStatus enums</returns>
        public static IEnumerable<DecisionStatus> GetDecisionStatuses(int meetingType)
        {
            // EventLog.Info(String.Format(Resources.log_evt_entry_DecisionStatus_GetDecisionStatuses, EventStatus.Entry.ToString(), meetingType));

            string[] statuses = BoardPACUtil.Settings.Settings.GetDecisionStatuses(meetingType);
            DecisionStatus tdecisionStatus;

            foreach (string enumName in Enum.GetNames(typeof(DecisionStatus)))
            {
                if (statuses.Contains(enumName) && Enum.TryParse(enumName, out tdecisionStatus))
                {
                    // EventLog.Info(String.Format(Resources.log_evt_success_DecisionStatus_GetDecisionStatuses, EventStatus.Success.ToString(), meetingType));

                    yield return tdecisionStatus;
                }
            }
        }

        /// <summary>
        /// Parsing the database value to the enum
        /// </summary>
        /// <param name="value">database value</param>
        /// <returns>DecisionStatus enum</returns>
        public static DecisionStatus GetEnum(int value)
        {
            switch (value)
            {
                case (int)DecisionStatus.Pending: return DecisionStatus.Pending;
                case (int)DecisionStatus.Approve: return DecisionStatus.Approve;
                case (int)DecisionStatus.Reject: return DecisionStatus.Reject;
                case (int)DecisionStatus.Abstain: return DecisionStatus.Abstain;
                case (int)DecisionStatus.Interest: return DecisionStatus.Interest;
                case (int)DecisionStatus.RPT: return DecisionStatus.RPT;
            }

            throw new ApplicationException(string.Format("There is no mapping DecisionStatus enum for the value {0}", value));
        }
    }

    #endregion
}
